//package com.march.service.Impl;
//
//import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
//import com.march.entry.Employee;
//import com.march.entry.LoginEmployee;
//import com.march.mapper.EmployeeMapper;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.security.core.userdetails.UserDetails;
//import org.springframework.security.core.userdetails.UserDetailsService;
//import org.springframework.security.core.userdetails.UsernameNotFoundException;
//
//import java.util.Objects;
//
//public class EmployeeDetailsServiceImpl implements UserDetailsService{
//
//        @Autowired
//        private EmployeeMapper employeeMapper;
//
//        @Override
//        public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
//            //根据用户名查询用户信息
//            LambdaQueryWrapper<Employee> wrapper = new LambdaQueryWrapper<>();
//            wrapper.eq(Employee::getUsername,username);
//            Employee user = employeeMapper.selectOne(wrapper);
//            //如果查询不到数据就通过抛出异常来给出提示
//            if(Objects.isNull(user)){
//                throw new RuntimeException("用户名或密码错误");
//            }
//            //TODO 根据用户查询权限信息 添加到LoginUser中
//
//            //封装成UserDetails对象返回
//            return new LoginEmployee(user);
//    }
//}
